package com.cfpl.userinfo.service.impl;

import com.cfpl.pojo.po.UserInfo;
import com.cfpl.userinfo.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.stereotype.Service;

import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.util.List;
@Service
public class UserInfoServiceImpl implements UserInfoService {
    @Autowired
    private EntityManager entityManager;
    @Override
    public List<UserInfo> queryPage(int currentPage, int pageSize) {
        String jpql = "select u from userinfo u";
        Query query = entityManager.createQuery(jpql);
        query.setFirstResult((currentPage-1)*pageSize);
        query.setMaxResults(pageSize);
        return query.getResultList();
    }
}
